package system;


import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author ciummo
 */
public class LoginActionForm extends org.apache.struts.action.ActionForm {
    
    private String username;
    private String password;
    private String role;
    private String cookies;
    private String sessionId;

    
    /**
     * @return
     */
    public String getUsername() {
        return username;
    }

    public String getRole(){
        return role;
    }
    
    public void setRole(String string){
        
        this.role = string;
    }
    /**
     * @param string
     */
    public void setUsername(String string) {
        username = string;
    }

    /**
     * @return
     */
    public String getPassword() {
        return password;
    }

    /**
     * @param i
     */
    public void setPassword(String string) {
        password = string;
    }
    
    public String getCookies(){
        
        return cookies;
    }
    
    public void setCookies(String cookies){
        
        this.cookies=cookies;
    }
    
    public String getSessionId (){
        
        return sessionId;
    }
    
    public void setSessionId(String sessionId){
        
        this.sessionId = sessionId;
    }
    
    

    /**
     *
     */
    public LoginActionForm() {
        super();

    }
    
    public LoginActionForm( String username, String password, String role, String sessionId ){
        
        this.username = username;
        this.password = password;
        this.role = role;
        this.sessionId = sessionId;
    }
    
    @Override
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        //CheckUserPassword cup = new CheckUserPassword();
        
        if (username == null || username.length() < 1) {
            errors.add("userName", new ActionMessage("error.login.username"));

        }
        else if (password == null || password.length() < 1) {
            errors.add("password", new ActionMessage("eerror.login.password"));

        }
        
        //else if (!cup.check(username,password)){
            
        //    errors.add("check", new ActionMessage("error.check.fail"));
        //}
        
        
        return errors;
    }
    
    @Override
    public void reset(ActionMapping mapping, HttpServletRequest request) {
		// reset properties
		cookies = "false";

	}
    
}